﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace xna_game_engine.source
{
    public class State_Pause : State_Base
    {
        // Members
        CGameScreen mScreen;

        // Functions
        public State_Pause(StateMachine.States Id) : base(Id)
        {
            mName = "Pause";
            mScreen = new CGameScreen();
            mScreen.AddElement(new CScreenElementImage("screens//pause_menu_background", Vector2.Zero));
            mScreen.AddElement(new CScreenElementText(new Vector2(450.0f, 384.0f), Color.White, "Pause Menu"));


            // Add our event handlers...
            mEventHandlers[EventManager.Events.EVT_START_HIT] = new EventHandler(OnEnter);
        }

        private void OnEnter()
        {
            Console.WriteLine("Pause: Transitioning to Gameplay State...");
            GameSystems.Audio.PlaySoundCue("level_up");
            GameGlobals.StateMachine.Transition(StateMachine.States.STATE_GAMEPLAY);

        }

        // Parental Overrides (forced)
        public override void  Init()
        {
            Console.WriteLine("Pause Init()...");
            mScreen.Init();
 	        //throw new System.NotImplementedException();
        }

        public override void Enter()
        {
            Console.WriteLine("Pause Enter()...");
            mParent = GameGlobals.StateMachine.GetState(StateMachine.States.STATE_GAMEPLAY);
            //throw new NotImplementedException();
        }

        public override void Update(GameTime gameTime)
        {
            mScreen.Update(gameTime);
            //Console.WriteLine("Main Menu Update()...");
            //throw new NotImplementedException();
        }

        public override void Exit()
        {
            Console.WriteLine("PauseExit()...");
            //throw new NotImplementedException();
        }

        public override void Draw()
        {
            mParent.Draw();
            mScreen.Draw();
        }
    }
}
